import sys
from itertools import groupby
from collections import defaultdict, Counter
n, m = sys.stdin.readline().split(maxsplit=1)
n = int(n)
m = int(m)
queens = []
for line in sys.stdin:
if line == '':
break
line = line.strip()
x, y = line.split(maxsplit=1)
queens.append((int(x), int(y)))
def f1(x):
return x[1], x[0]
def f2(x):
return x[0], x[1]
def f3(x):
return x[1] + x[0], x[1]
def f4(x):
return x[1] - x[0], x[1]
def f5(x):
return x[1]
def f6(x):
return x[0]
def f7(x):
return x[1] + x[0]
def f8(x):
return x[1] - x[0]
lambdas = [f1, f2, f3, f4]
g_lambdas = [f5, f6, f7, f8]
if len(queens) != m:
raise ValueError("wrong queen numbe8r!")
attacks = defaultdict(lambda: 0)
for sl, gl in zip(lambdas, g_lambdas):
s_queens = sorted(queens, key=sl)
a = (list(g) for k, g in groupby(s_queens, key=gl))
for g in a:
if len(g) == 1:
attacks[g[0]] += 0
else:
attacks[g[0]] += 1
attacks[g[-1]] += 1
for k in g[1:-1]:
attacks[k] += 2
output = [0] * 9
for k, v in Counter(attacks.values()).items():
output[k] = v
print(*output)
543. Diameter of Binary Tree | 124. Binary Tree Maximum Path Sum |
1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts | 501A - Contest |
160A- Twins | 752. Open the Lock |
1535A - Fair Playoff | 1538F - Interesting Function |
1920. Build Array from Permutation | 494. Target Sum |
797. All Paths From Source to Target | 1547B - Alphabetical Strings |
1550A - Find The Array | 118B - Present from Lena |
27A - Next Test | 785. Is Graph Bipartite |
90. Subsets II | 1560A - Dislike of Threes |
36. Valid Sudoku | 557. Reverse Words in a String III |
566. Reshape the Matrix | 167. Two Sum II - Input array is sorted |
387. First Unique Character in a String | 383. Ransom Note |
242. Valid Anagram | 141. Linked List Cycle |
21. Merge Two Sorted Lists | 203. Remove Linked List Elements |
733. Flood Fill | 206. Reverse Linked List |